<?php

/**
 * 找钱花产品模型层
 * Date: 12/8/17
 * Time: 15:25
 */

namespace Home\Model;
use Common\Library\BusinessException;
use Think\Log;
use Think\Model;
use Common\Library\Constant;
use Common\Library\CacheRedis;

class SysInstallmentPlanModel extends Model{

    const STATUS_UN_REVIEWED = 0; //没有审核
    const STATUS_REVIEWED = 1; //已完成
    const STATUS_FAXI = 0.02;
    /**
     * 找钱花产品
     * @param
     * @return 现有全部产品详情|
     */
    public function getProducts()
    {
         $products=M('SysInstallmentPlan')->field('id,repay_times,interest_rate,target,cut_interest,publish,repay_unit,timer')->select();
         //echo  M('SysInstallmentPlan')->getLastSql();
         //var_dump($products);
         return $products;
    }
    public function getProductsIds()
    {
        $products=M('SysInstallmentPlan')->field('id')->select();
        $ids=[];
        foreach($products as  $v){
            $ids[]=$v['id'];
        }
        return $ids;
    }
    public function getProductDays()
    {
        $products=M('SysInstallmentPlan')->field('id,timer')->select();
        $ids=[];
        foreach($products as  $v){
            $ids[$v['id']]=$v['timer'];
        }
        return $ids;
    }
    /**
     * 找钱花产品
     * @param @id
     * @return 根据产品id查看产品详情|
     */
    public function getProductById($id)
    {
        $products=M('SysInstallmentPlan')->field('id,repay_times,interest_rate,target,cut_interest,publish,repay_unit,timer')->where(['id'=>$id])->find();
        //echo  M('SysInstallmentPlan')->getLastSql();
        //var_dump($products);
        return $products;
    }


}

